﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TimeSyncUtil
{
    public static class StringUtil
    {
        public static double ToDouble(this string str)
        {
            if (double.TryParse(str, out double d))
            {
                return d;
            }
            else
            {
                return 0;
            }
        }
        public static double ToDouble(this object str)
        {
            if (str == null) return 0;
            if (double.TryParse(str.ToString(), out double d))
            {
                return d;
            }
            else
            {
                return 0;
            }
        }
    }
}
